﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AutoShot : MonoBehaviour {

    [Tooltip("射出的子弹类型")]
    public Shot shotType = Shot.RAY;
    [SerializeField, Tooltip("激光枪的伤害值")]
    private Damage damage;
    [SerializeField, Tooltip("发射子弹位置到人物中心的距离")]
    private float distance_Gun = 1f;
    [SerializeField,Tooltip("目标")]
    private Vector3 tagert;
    [SerializeField, Tooltip("射击时间间隔")]
    private float shotTime = 1;
    private float timer = 0;
    private Vector3 startPos;

    void Update () {
        timer += Time.deltaTime;
        if (timer>shotTime)
        {
            startPos = transform.position + distance_Gun * tagert.normalized;
            Shots.Shot(tagert , startPos, (int)shotType, damage);
            timer = 0;
        }
    }


    private void OnDrawGizmos()
    {
        Gizmos.DrawLine(transform.position,transform.position+ tagert);
    }
}
